<!-- templates/speech_result.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>花艺AI - 语音查询结果</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body { padding-top: 2rem; }
        .header { margin-bottom: 2rem; }
        .container { max-width: 800px; margin: 0 auto; }
        .result-card { border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
        .transcription { color: #555; margin-bottom: 15px; }
        .response { background-color: #f5f5f5; padding: 15px; border-radius: 5px; }
        .image-container { margin: 20px 0; }
        .image-container img { max-width: 100%; border: 1px solid #eee; }
        .audio-container { margin: 20px 0; }
        audio { width: 100%; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header text-center">
            <h1>花艺AI测试应用</h1>
            <p class="lead">语音查询结果</p>
            <nav class="nav justify-content-center">
                <a class="nav-link" href="/">首页</a>
                <a class="nav-link" href="/upload">上传知识</a>
                <a class="nav-link" href="/image">生成图像</a>
                <a class="nav-link" href="/speech">语音交互</a>
                <a class="nav-link" href="/status">系统状态</a>
            </nav>
        </div>

        <div class="result-card">
            <div class="transcription">
                <h3>您的问题</h3>
                <p>{{ result.transcription }}</p>
                <p><small>方言: {{ result.dialect }}</small></p>
            </div>

            <div class="response">
                <h3>AI回答</h3>
                <p>{{ result.response }}</p>
                <p><small>来源: {{ result.source }}</small></p>
            </div>

            {% if result.image_url %}
            <div class="image-container">
                <h3>生成的花艺图像</h3>
                <img src="{{ result.image_url }}" alt="生成的花艺图像" class="img-fluid">
            </div>
            {% endif %}

            {% if result.audio_response %}
            <div class="audio-container">
                <h3>语音回答</h3>
                <audio controls autoplay>
                    <source src="data:audio/wav;base64,{{ result.audio_response }}" type="audio/wav">
                    您的浏览器不支持音频播放
                </audio>
            </div>
            {% endif %}
        </div>

        <div class="text-center">
            <a href="/speech" class="btn btn-primary">返回语音界面</a>
            <a href="/" class="btn btn-outline-secondary ms-2">返回首页</a>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>